FROM cmakelib/build-linux:latest-debian-buster as builder
RUN sed -i "s@http://\(deb\|security\).debian.org@https://mirrors.aliyun.com@g" /etc/apt/sources.list
RUN apt update
RUN apt install -y make g++
COPY icecode /app/icecode
WORKDIR /app/icecode
RUN cmake -B build -S .
RUN cmake --build build

FROM perl:5.39.4-threaded as runner
ENV AUTO_HOME=/home/etl
ENV AUTO_EDT_HOME=/home/etl/EDT
RUN sed -i -E 's/(deb|security).debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list.d/debian.sources
RUN apt update
RUN cpanm Net::SFTP::Foreign
RUN cpanm IO::Tty
RUN cpanm DBI
RUN groupadd etl
RUN useradd etl -g etl -m -s '/bin/bash'
COPY EDT /home/etl/EDT
COPY --from=builder /app/icecode/build/IceCode /home/etl/EDT/tools/IceCode.exe
RUN ln -s /home/etl/EDT/tools/IceCode.exe /home/etl/EDT/bin/IceCode.exe
RUN chmod +x /home/etl/EDT/bin/IceCode.exe
RUN su - etl
WORKDIR /home/etl
CMD ["perl", "EDT/bin/Extra_data_trans.pl"]
